package com.sali.common;

import com.sali.pojo.KafkaEntity;
import org.apache.commons.lang3.StringUtils;

import java.util.Properties;

public abstract class KafkaUtils {

    private static final Properties properties;

    static {
        properties = new Properties();
    }

    protected static Properties getKafkaProperties(String brokerIp) {
        properties.put("bootstrap.servers", brokerIp);
        return properties;
    }

    protected static void checkParams(KafkaEntity kafkaEntity) {
        String brokerIp = kafkaEntity.getBrokerIp();
        String kafkaTopic = kafkaEntity.getKafkaTopic();
        if (StringUtils.isBlank(brokerIp) ||
                StringUtils.isBlank(kafkaTopic)) {
            throw new RuntimeException("请检查kafka组件参数...");
        }

        if (kafkaEntity.getKafkaTopic().contains(",")) {
            throw new RuntimeException("当前只支持输入单个ip...");
        }

    }

}
